﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Topshelf;

namespace nwrole.SuperModule.service
{
    class Program
    {
        static int Main(string[] args)
        {
            var exitCode = HostFactory.Run(host =>
            {
                host.Service<SuperModuleApp>(service =>
                                        {
                                            service.ConstructUsing(() => new SuperModuleApp());
                                            service.WhenStarted(a => a.Start());
                                            service.WhenStopped(a => a.Stop());
                                        });

                host.SetDescription("Manages nwrole modules");
                host.SetDisplayName("nwrole SuperModule service");
                host.SetServiceName("nwrole.SuperModule.service");
                host.RunAsLocalSystem();
            });
            return (int) exitCode;
        }
    }

    class SuperModuleApp
    {
        public void Start()
        {
            try
            {
                SuperModule.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            
        }

        public void Stop()
        {
            SuperModule.Stop();
        }
    }
}
